//
//  PModel.swift
//  Parkour
//
//  Created by XiaoFeng on 2018/2/25.
//  Copyright © 2018年 新翼工作室. All rights reserved.
//

import HandyJSON


class BaseModel: HandyJSON {
 
    public required init() {}
}

/// 用户基础信息
class User: HandyJSON {

    var token: String = ""
    
    var expires_in: String = ""
    
    var id: String = ""
    
    var createtime: String = ""
    
    var username: String = ""
    
    var avatar: String = ""
    var user_id: String = ""
    var mobile: String = ""
    var score: String = ""
    var expiretime: String = ""
    var nickname: String = ""
    
    

    public required init() {}
    
}


private let kUserDict = "UserDict"

class UserManager {
    
    var currentUser: User?
    
    static let shared = UserManager()
    init() {
        queryCurrentUser()
    }
    
    private func queryCurrentUser() {
        guard let userDict = UserDefaults.standard.object(forKey: kUserDict) as? [String: Any] else { return }
        currentUser = JSONDeserializer<User>.deserializeFrom(dict: userDict)
    }
    
    func saveUserinfo() {
        let userDict = currentUser?.toJSON()
        UserDefaults.standard.set(userDict, forKey: kUserDict)
        let result = UserDefaults.standard.synchronize()
        // ~/Library/Preference/bundleId.plist
        print("保存用户信息 synchronize result：\(result)")

    }
        func signOut() {
            currentUser = nil
            saveUserinfo()
        }

}


/// 机票日历
@objc class PriceCalendarModel: NSObject, HandyJSON {

    @objc   var flightNo: String = ""
    
    @objc    var cabin: String = ""
    
    @objc    var discount: String = ""
    
    @objc    var barePrice: String = ""
    
    @objc   var tag: String = ""
    
    @objc  var departDate: String?

    

    public required override init() {}
    
}

/// 经济机票模型
@objc class JJTickeModel: NSObject, HandyJSON {

    @objc    var barePrice: Int = 0
  
    public required override init() {}
    
}


/// 经济机票模型
@objc class CityMainModel: NSObject,HandyJSON {

    var data: [CityModel]?
  
    public required override init() {}
    
}

class CityModel:NSObject, HandyJSON {
    var scenic_spot_id: Int = 0

    var city_id: Int = 0
    
    var id: Int = 0
    
    var city_name: String = ""
    
    var name: String = ""
  
    public required override init() {}
    
}


//规则模型

@objc class CityRuleMianModel: NSObject,HandyJSON {

    var data: CityRuleSomeModel?
  
    public required override init() {}
    
}

@objc class CityRuleSomeModel: NSObject,HandyJSON {

    var sortList: [sortList]?
    var priceList: [priceList]?
    var numberList: [numberList]?
    
    var dayList: [dayList]?
  
    public required override init() {}
    
}

@objc class sortList: NSObject,HandyJSON {

    var id: Int = 0
    
    var name: String = ""

    public required override init() {}
    
}

@objc class priceList: NSObject,HandyJSON {

    var keyword: String = ""
    
    var infolist: [infolist]?

    public required override init() {}
    
}

@objc class infolist: NSObject,HandyJSON {

    var min: Int = 0
    
    var max: Int = 0

    var keyword: String = ""
    
    var id: Int = 0

    var name: String = ""
    public required override init() {}
    
}

@objc class numberList: NSObject,HandyJSON {

    var keyword: String = ""
    
    var infolist: [infolist]?
    public required override init() {}
    
}

@objc class dayList: NSObject,HandyJSON {

    var keyword: String = ""
    
    var infolist: [infolist]?
    public required override init() {}
    
}


@objc class CitySpotListMianModel: NSObject,HandyJSON {

    var data: [CitySpotListModel]?
  
    public required override init() {}
    
}

@objc class CitySpotListModel: NSObject,HandyJSON {

    var country_id: Int = 0
    var province_id: Int = 0
    var url:String = ""
    var province_name:String = ""
    
    var longitude:String = ""
    
    var price:String = ""
    
    var product_add_info_list:String = ""
    
    var province_ename:String = ""
    
    var comment_grade:String = ""
    
    var latitude:String = ""
    
    var id:Int = 0
    
    var city_id:Int = 0
    
    var city_ename:String = ""
    
    var product_description:String = ""
    
    var market_price:String = ""
    
    var name:String = ""
    
    var city_name:String = ""
    
    var is_can_booking:String = ""
    
    var open_time_desc:String = ""
    
    var ctrip_price:String = ""
    
    var country_ename:String = ""
    
    
    var country_name:String = ""
    
    var image_url:String = ""
    
    var scenic_spot_id:String = ""
    
    var star:String = ""

    
    public required override init() {}
    
}


 class CityHotelMianModel: HandyJSON {

    
    
    var roomPriceItem: [roomPriceItem]?
    
    var description:String = ""
    
    var zoneName:String = ""
    
    var hotelName :String = ""
    
    var hotelStarLicence :String = "" //星级
    
    var bulitTime:String = ""//建造时间
    
    var firstImg:String = ""//酒店头图
    
    var mobile:String = "" //电话
    
    var hotelStarRate:String = ""//酒店评分
    
    var addressLine:String = ""
    
    var parentServicesName:String = ""
    
    var serviceName:String = ""
    
    var policy:[policy]?
  
    public required init() {}
    
}


@objc class roomPriceItem: NSObject,HandyJSON {

    var baseRoomInfo:baseRoomInfo?

  
    public required override init() {}
    
}

@objc class imageList: NSObject,HandyJSON {

    var RoomTypeName:String = ""
    
    var roomImageUrl:String = ""
    
    var HotelId:String = ""
  
    public required override init() {}
    
}

@objc class policy: NSObject,HandyJSON {

    var ploicyName:String = ""
    
    var policyText:String = ""
  
  
    public required override init() {}
    
}


class CityHotelDetailMianModel: HandyJSON {

   var data: [CityHotelDetailModel]?
   
   
 
   public required init() {}
   
}

class CityHotelDetailModel: HandyJSON {

   var minprice: String = ""
   
    var roomInfo: [roomInfo]?
    
    var baseRoomInfo:baseRoomInfo?
 
   public required init() {}
   
}

class roomInfo: HandyJSON {


    var isHourRoom:String = ""
    var hasWindow: String = ""
    var invoiceTargetType: String = ""
    
    var promotionInfo: promotionInfo?
    
    var person: String = ""
    
    var addBedFee: String = ""
    
    var roomPriceInfo: roomPriceInfo?
 
    var roomBedTypeInfo: roomBedTypeInfo?
    var children: String = ""
    var roomID: String = ""
    var areaRange: String = ""
    var isSupportAnticipation: String = ""
    var isGuaranteed: String = ""
    var supplierId: String = ""
    
    var roomName: String = ""
    
    var cancelLimitInfo: cancelLimitInfo?
    
    
   public required init() {}
   
}

class smokeInfo: HandyJSON {

    var notAllowSmoking:String = ""


   public required init() {}
   
}

class cancelLimitInfo: HandyJSON {

    var cancelPolicyInfo:String = ""
    
    var policyType:String = ""
    
    var lastCancelTime:String = ""

   public required init() {}
   
}

class roomBedTypeInfo: HandyJSON {

    var singleBedWidth:String = ""
    
    var kingBedWidth:String = ""
    
    var roomBedName:String = ""
    
    var twinBedWidth:String = ""
    
    var hasTwinBed:String = ""
    
    var hasSingleBed:String = ""
    
    var hasKingBed:String = ""

   public required init() {}
   
}


class roomPriceInfo: HandyJSON {

    var payType:String = ""
    
    var roomPriceDetail:[roomPriceDetail]?
    
    var averagePrice:averagePrice?
    
    var remainingRooms:String = ""
    
    var isGuarantee:String = ""
    
    var isCanReserve:String = ""
    
    var ratePlanCategory:String = ""
    
    var isJustifyConfirm:String = ""
    
    var checkInEveryPriceList:[checkInEveryPriceList]?

   public required init() {}
   
}


class checkInEveryPriceList: HandyJSON {

    var effectDate:String = ""
    
    var breakfast:String = ""
    
    var payPrice:String = ""
    
    var listingPrice:String = ""
    

   public required init() {}
   
}

class averagePrice: HandyJSON {

    var amount:String = ""
    
    var settleFee:String = ""
    
    var currency:String = ""
    
    var averageprice:String = ""
    
    var cNYAmount:String = ""

   public required init() {}
   
}

class roomPriceDetail: HandyJSON {

    var roomStatus:String = ""
    
    var effectDate:String = ""
    
    var price:price?
    
    var breakfast:String = ""

   public required init() {}
   
}

class price: HandyJSON {

    var cNYAmount:String = ""
    
    var amount:String = ""
    
    var currency:String = ""

   public required init() {}
   
}



class promotionInfo: HandyJSON {

    var text:String = ""

   public required init() {}
   
}


class baseRoomInfo: HandyJSON {

    var person: String = ""
   
    var areaRange: String = ""
    
    var hasWindow: String = ""
    
    var roomName: String = ""
    
    var roomTypeID: String = ""
    
    var serviceNames: String = ""
    
    var roomImageUrl: String = ""
    
    var bedTypeInfo: [bedTypeInfo]?
    var smokeInfo:smokeInfo?
 
   public required init() {}
   
}

class bedTypeInfo: HandyJSON {

    var bedCount: String = ""
   
    var bedWidth: String = ""
    
    var bedName: String = ""
    
    var bedType: String = ""
 
   public required init() {}
   
}

class NewsMainModel: HandyJSON {

    var data: [NewsModel]?
   
 
   public required init() {}
   
}

class NewsModel: HandyJSON {

    var name: String = ""
    
    var list:[NewsDetailModel]?
   public required init() {}
   
}

class NewsDetailModel: HandyJSON {

    var id: String = ""
    var name: String = ""
    var image: String = ""
    var create_time: String = ""
    var nums: String = ""
    
 
   public required init() {}
   
}

class NewsContentModel: HandyJSON {

    var id: String = ""
    var name: String = ""
    var image: String = ""
    var create_time: String = ""
    var nums: String = ""
    var content: String = ""
 
   public required init() {}
   
}


class hotelAvailModel: HandyJSON {

    var canBook:Bool = false
   
    var checkPrice:Int = 0
    
    var availableQuantity:Int = 0
 
   public required init() {}
   
}

class createHotelOrderModel: HandyJSON {

    var order_id:String = ""

   public required init() {}
   
}


@objc class TravelDetailMianModel: NSObject,HandyJSON {

    var data: [TravelDetailModel]?
  
    public required override init() {}
    
}

@objc class TravelDetailModel: NSObject,HandyJSON {

    var Address:String = ""
    
    var ImageURL:String = ""
    
    var URL:String = ""
    
    var Price:String = ""
    
    var ShowStartingPriceType:String = ""
    
    var PMRecommand:String = ""
    
    var Name:String = ""
    
    var CtripPrice:String = ""
    
    var ID:String = ""
    
    var DisplayPrice:String = ""
    
    var OpenTimeDesc:String = ""
    
    var IsCanBooking:String = ""
    
    var Star:String = ""
    
    var Longitude:String = ""
    
    var ProductInfo:ProductInfo?
 
    public required override init() {}
    
}

@objc class ProductInfo: NSObject,HandyJSON {

    var ResourceList:[ResourceList]?
  
    public required override init() {}
    
}


@objc class ResourceList: NSObject,HandyJSON {

    var Name:String = ""
    
    var IsSaleAlone:String = ""
    
    
    var CustomerInfoTemplateID:String = ""
    
    var EffectiveDays:String = ""
    
    var PeopleGroup:String = ""
    
    var CategoryID:String = ""
    
    var TicketType:String = ""
    
    var ID:String = ""
    
    var MarketPrice:String = ""
    
    var CtripPrice:String = ""
    
    var Price:String = ""
    
    var AdvanceBookingTime:String = ""
    
    var DisplayTagGroupList:[DisplayTagGroupList]?
  
    public required override init() {}
    
}

@objc class DisplayTagGroupList: NSObject,HandyJSON {

    var DisplayTagList: [DisplayTagList]?
  
    public required override init() {}
    
}

@objc class DisplayTagList: NSObject,HandyJSON {

    var Key:String = ""
    
    var Value:String = ""
  
    public required override init() {}
    
}
